Natural Order is a System Extension that improves the sorting order that your Macintosh uses when it displays lists of items.
If you have a group of numbered files on your disk and you select メView By Nameモ in the Finder, you might expect the files to be displayed in sensible numerical order, like this:
Picture1.jpg
Picture2.jpg
Picture3.jpg
Picture4.jpg
Picture5.jpg
Picture6.jpg
Picture7.jpg
Picture8.jpg
Picture9.jpg
Picture10.jpg
Picture11.jpg
Picture12.jpg
If youユve ever had a group of numbered files on your disk, youユll know that the Finder doesnユt do this. When you select メView By Nameモ what you get looks like this:
Picture1.jpg
Picture10.jpg
Picture11.jpg
Picture12.jpg
Picture2.jpg
Picture3.jpg
Picture4.jpg
Picture5.jpg
Picture6.jpg
Picture7.jpg
Picture8.jpg
Picture9.jpg
This looks stupid, and itユs because the System is just sorting the names lexicagraphically. By the same logic that dictates that メabモ comes alphabetically before メcモ (which is correct) the System decides that メ12モ comes before メ3モ (which is stupid). Dユoh! Natural Order works by overriding the Systemユs comparison of the numerical portions of strings, and sorts them by numerical value instead of メalphabeticalモ value.
How to use Natural Order
Drop Natural Order into the System Folder and Restart your Mac.
Restrictions
Natural Order has only been tested on System 7.5.x. It should work on other Systems, but I have not personally tested it.
Natural Order works by overriding the Systemユs IUMagString and IUMagPString functions. Programs that use their own sorting order and do not call the Systemユs comparison routines will not get any benefit from Natural Order.
Natural Order only overrides the sorting of the numeric parts of strings. It still uses your Systemユs built-in sorting function for the textual parts of strings, so if you have your system set to some foreign sorting order, that order will still be honoured by Natural Order.
Programs that benefit from Natural Order
The Finder (for メView by nameモ file lists)
Standard File Dialogs (for opening and saving files, in any application)
The Chooser (for the lists of zone names, file servers, etc.)
Bolo (for sorting the list of zone names when you start an AppleTalk game)
If you find other programs that benefit from Natural Order, please let me know so I can add them to the list.
Programs that do not benefit from Natural Order
Nuntius 2.0.4 (for displaying lists of articles)
Fetch 3.0.1 (for displaying listings of ftp sites sorted by name)
Anarchie 1.6.0 (for displaying listings of ftp sites sorted by name)
If you find other programs that do not benefit from Natural Order, please let me know about those as well, so I can add them to the list, and contact the authors to see what they think about changing their programs to use natural sorting order.
It is disappointing to find that so few programs use the Macユs International Utilities (IU) sorting routines. Now that Natural Order exists, I hope that more programs will start using the IU routines to get the benefit of improved sorting order.
Programs that do not need Natural Order
Anarchie 2.0 and later [currently in development] (for displaying listings of ftp sites sorted by name)
Peter Lewis liked the idea of Natural Order, but found that calling the IU sorting routines was too slow when youユre listing a directory containing over 5000 files, so he programmed the Natural Order sorting algorithm directly into Anarchie.
The overhead of calling the IU sorting routines should not be significant for most programs. Some people, like people whose primary language is not English, may prefer to have their lists sorted a different way. Using the IU routines allows the System Software to give them their preferred sorting order, and using the IU routines with Natural Order installed gives them their preferred sorting order with smart numerical sorting as well. If your Macintosh software uses the IU routines and you want numerical sorting, you may bundle Natural Order with your software, along with this ReadMe file.
Still, if youユre sorting thousands of items and the speed penalty of using the IU routines is too much, you may incorporate the Natural Order algorithm in your software, just as long as you give me credit for it. See below for details of where to find the source code.
Frequently Asked Questions
Can I have source code for Natural Order?
You can get it by anonymous ftp from my Mac at home, bolo.stanford.edu.
Look in "Public/Stuart's tech notes/Natural Order"
Licence
Natural Order is freeware. Providing that you acknowledge my authorship, you may distribute it any way you like, or do anything else with it, including producing derivative works from the source code. If my source code allows you to improve the user interface of your software, then I will be happy to have made a small contribution to improving the lives of computer users.
Version History
0.9 Friday 21st June 1996, written overnight at MacHack, due to persistent cajoling by Quinn.
1.0 Monday 4th November 1996. Added an icon, added some balloon help, fixed a potential glitch in sorting order in some cases (for the technically inclined, Natural Order now overrides IUMagPString as well as IUMagString) and sent it off to Sumex-Aim.